package file;

public class ForLoopDemo2 {
    public static void main(String[] args) {
        //定义数组：存储3个社团的报名人数
        int[] clubCounts = {25,32,18};
        String[]clubNames = {"编程社","动漫社","志愿者社"};
        int allTotal = 0;//所有社团总人数

        //增强for循环：遍历社团人数数组
        System.out.println("各社团报名人数：");
        for (int count:clubCounts) {
            //循环变量count直接获取数组中的每个元素值
            System.out.println(count+"人");
            allTotal += count;
        }
        //普通for循环：关联社团名称与人数（需要索引）
        System.out.println("\n 社团名称-报名人数明细：");
        for (int i = 0; i <clubNames.length; i++) {
            System.out.println(clubNames[i] +":" + clubCounts[i] +"人");
        }

        System.out.println("\n 所有社团总报名人数："+allTotal);
    }
}
